/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

package com.zog
{
    import com.pblabs.animation.PointAnimator;
	import com.pblabs.components.basic.HealthComponent;
    import com.pblabs.engine.components.TickedComponent;
    import com.pblabs.engine.core.ObjectType;
	import com.pblabs.engine.entity.EntityComponent;
	import com.pblabs.engine.entity.PropertyReference;
    import com.pblabs.engine.PBE;
    import com.pblabs.engine.debug.Logger;
	
	import flash.events.Event;
    import com.pblabs.components.basic.HealthEvent;
	import flash.geom.Point;
    
    import com.pblabs.box2D.Box2DSpatialComponent;
    import com.pblabs.animation.AnimatorComponent;

    //TODO: is ticked really needed?
	public class SpaceShipLogic extends EntityComponent //TickedComponent
	{
		protected override function onAdd():void
		{
			super.onAdd();
			owner.eventDispatcher.addEventListener(HealthEvent.DIED, onDied);
		}
		
		protected override function onRemove():void
		{
			super.onRemove();
			owner.eventDispatcher.removeEventListener(HealthEvent.DIED, onDied);
		}
		
        /*
        public override function onTick(tickRate:Number):void
        {
            if(killPlayer)
            {
                killPlayer = false;
                onKillPlayer();
            }
        }*/

		protected function onDied(event:HealthEvent):void
		{
            PBE.callLater(owner.destroy);
           //killPlayer = true;
		}
   	}
}